package il.technion.cs236369.webserver.simpleServlets;

import java.util.HashSet;

public class UserDistanceSession extends UserSession{
	private HashSet<GeoCoordinate> coordCollection;
	private double maxDistance = -1;
	
	private GeoCoordinate farthest1 = null;
	private GeoCoordinate farthest2 = null;

	public UserDistanceSession(){
		super();
		this.coordCollection = new HashSet<GeoCoordinate>();
	}
	
	public void AddCoordinate(GeoCoordinate inCoord){
		
		//updating max distance
		for (GeoCoordinate coord : this.coordCollection) {
			double currentDistance = GeoCoordinate.EuclidianDistance(inCoord, coord);
			if (maxDistance<currentDistance){
				this.farthest1=coord;
				this.farthest2=inCoord;
				this.maxDistance = currentDistance;
			}
		}
		
		//
		this.coordCollection.add(inCoord);
	}

}
